﻿using Common.MQ;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;

namespace Common.Web
{
    /// <summary>
    /// http性能测量
    /// </summary>
    public class HttpMeasureModel : IMessageModel
    {
        /// <summary>
        /// 应用ID
        /// </summary>
        public string AppId { get; set; }
        /// <summary>
        /// 应用名称
        /// </summary>
        public string AppName { get; set; }
        /// <summary>
        /// 环境
        /// </summary>
        public string Env { get; set; }
        /// <summary>
        /// 请求路径
        /// </summary>
        public string Path { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string Scheme { get; set; }
        /// <summary>
        /// 请求主机
        /// </summary>
        public string Host { get; set; }
        /// <summary>
        /// 请求方法（GET,POST,PUT...etc.）
        /// </summary>
        public string Method { get; set; }
        /// <summary>
        /// 耗时（毫秒）
        /// </summary>
        public long Elapsed { get; set; }
        /// <summary>
        /// 请求ID
        /// </summary>
        public string RequestId { get; set; }
        /// <summary>
        /// 查询参数
        /// </summary>
        public string QueryString { get; set; }
        /// <summary>
        /// 时间戳（毫秒）
        /// </summary>
        public long TimeStampMs { get; set; }
        /// <summary>
        /// 状态码
        /// </summary>
        public int StatusCode { get; set; }
        /// <summary>
        /// 用户代理
        /// </summary>
        public string UserAgent { get; set; }
        /// <summary>
        /// 消息目的地
        /// </summary>
        [JsonIgnore]
        public string Destination { get; set; }
        /// <summary>
        /// 消息属性
        /// </summary>
        /// <returns></returns>
        public MessageProperty GetProperties()
        {
            return null;
        }
        /// <summary>
        /// 消息目的地
        /// </summary>
        /// <returns></returns>
        public string GetDestination()
        {
            return this.Destination;
        }
        /// <summary>
        /// 获取消息json
        /// </summary>
        /// <returns></returns>
        public string GetMessageJson()
        {
            return Common.Json.JsonSerializer.JsonSerialize(this);
        }
        /// <inheritdoc/>
        public string GetMessageType()
        {
            return "HttpMeasureModel";
        }
    }
}
